package d7_homework.d1_homework.d1_firstquestion;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class FirstQuestion {
    public static void main(String[] args) {
        //目标: 训练Comparator, 增强for, Collections
        //创建集合,存储学生信息
        List<Student> students = new ArrayList<>();

        //利用collections的方法进行加数据
        Collections.addAll(students,
                new Student(001, "陈平安", 99),
                new Student(002, "宁姚", 98),
                new Student(003, "叶凡", 101),
                new Student(004, "姬紫月", 95)
        );

        //利用Collections中的sort方法进行排序
        Collections.sort(students, (m,n) -> Double.compare(n.getScore(),m.getScore()));

        //利用增强for进行遍历,然后展示所有信息
        for (Student student : students) {
            System.out.println(student);
        }
    }
}
